package com.zy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zy.entity.User;
import com.zy.entity.ZyUser;
import com.zy.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> {

    @Autowired
    UserMapper userMapper;

    /**
     * 分页
     * @param page
     * @param limit
     * @return
     */
    public Map selectByPage(Integer page,Integer limit){
        Page<User> userPage = new Page<>(page,limit);
        QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
        Page<User> findPage = userMapper.selectPage(userPage, null);
        HashMap<String, Object> map = new HashMap<>();
        List<User> records = findPage.getRecords();
        map.put("users",records);
        map.put("total",findPage.getTotal());
        return map;
    }

}
